package encheres.dao.entities;

// Generated 17 mars 2011 18:44:21 by Hibernate Tools 3.3.0.GA

import java.util.Date;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;


/**
 * Vente generated by hbm2java
 */
@Entity
@Table(name = "vente", catalog = "encheres")
public class Vente implements java.io.Serializable, Comparable<Vente> {

	private VenteId id;
	private Produit produit;
	private Client client;
	private Float prixVente;

	public Vente() {
	}

	public Vente(VenteId id, Produit produit, Client client) {
		this.id = id;
		this.produit = produit;
		this.client = client;
	}

	public Vente(VenteId id, Produit produit, Client client, Float prixVente) {
		this.id = id;
		this.produit = produit;
		this.client = client;
		this.prixVente = prixVente;
	}

	@EmbeddedId
	@AttributeOverrides({
			@AttributeOverride(name = "idClient", column = @Column(name = "idClient", nullable = false)),
			@AttributeOverride(name = "idProduit", column = @Column(name = "idProduit", nullable = false)),
			@AttributeOverride(name = "dateVente", column = @Column(name = "dateVente", nullable = false, length = 0)) })
	public VenteId getId() {
		return this.id;
	}

	public void setId(VenteId id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "idProduit", nullable = false, insertable = false, updatable = false)
	public Produit getProduit() {
		return this.produit;
	}

	public void setProduit(Produit produit) {
		this.produit = produit;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "idClient", nullable = false, insertable = false, updatable = false)
	public Client getClient() {
		return this.client;
	}

	public void setClient(Client client) {
		this.client = client;
	}

	@Column(name = "prixVente", precision = 12, scale = 0)
	public Float getPrixVente() {
		return this.prixVente;
	}

	public void setPrixVente(Float prixVente) {
		this.prixVente = prixVente;
	}
	
	public int compareTo(Vente obj) {
		return obj.id.getDateVente().compareTo(this.id.getDateVente());
	}

}
